package com.wjc.train.business.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wjc.train.business.req.DailyTrainSeatQueryReq;
import com.wjc.train.business.req.DailyTrainSeatSaveReq;
import com.wjc.train.business.resp.DailyTrainSeatQueryResp;
import com.wjc.train.business.service.IDailyTrainSeatService;
import com.wjc.train.common.resp.CommonResp;
import com.wjc.train.common.untils.PageUtil;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 每日座位表 前端控制器
 * </p>
 *
 * @author Guessed
 * @since 2023-08-08
 */
@RestController
@Validated
@RequestMapping("/admin/daily-train-seat")
public class DailyTrainSeatController {

    @Resource
    private IDailyTrainSeatService dailytrainseatService;

    @PostMapping("/save")
    public CommonResp save(@RequestBody @Valid DailyTrainSeatSaveReq dailytrainseatSaveReq){
        dailytrainseatService.save(dailytrainseatSaveReq);
        return CommonResp.success();
    }

    @PostMapping("/query-list")
    public CommonResp save(@RequestBody DailyTrainSeatQueryReq dailytrainseatQueryReq){
        IPage<DailyTrainSeatQueryResp> iPage =
        dailytrainseatService.queryList(PageUtil.getPage(dailytrainseatQueryReq.getQueryPage()), dailytrainseatQueryReq);
        return CommonResp.success(new PageUtil(iPage));
    }

    @DeleteMapping ("/delete/{id}")
    public CommonResp delete(@PathVariable Long id){
        dailytrainseatService.delete(id);
        return CommonResp.success();
    }


}


